package com.chenyuxin.ilp.controller.user;

import com.chenyuxin.ilp.model.pojo.Result;
import com.chenyuxin.ilp.service.user.UserHeadService;
import com.chenyuxin.ilp.util.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/user/head")
public class UserHeadController {
    @Autowired
    private UserHeadService userHeadService;
    @GetMapping("/list")
    public Result getHeadList(){
        String userId = SecurityUtil.getUserId();
        return userHeadService.getHeadList(userId);
    }
    @PostMapping("/add")
    public Result addHead(@RequestPart("head")MultipartFile headFile){
        String userId = SecurityUtil.getUserId();
        return userHeadService.addHead(headFile,userId);
    }
    @PutMapping("/update/{headid}")
    public Result updateHead(@PathVariable("headid")Long headId){
        String userId = SecurityUtil.getUserId();
        return userHeadService.updateHead(headId,userId);
    }
}
